Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewer auto suspend rendering when scene is idle #15864

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

ryantrem
Copy link
Member

This PR adds support for suspending rendering when the scene is idle (e.g. nothing is changing from frame to frame, and the same exact pixels would be rendered repeatedly). The idea is to reduce resource pressure and not destroy the battery on a mobile device.

I have two problems remaining for this PR:

  1. Sometimes (it's hard to repro) I can get into a state where the camera position jumps back and forth between two very close positions (like the y value of the position has a difference of .000000000001). This makes _isSynchronizedProjectionMatrix return true every frame. I don't think this has anything to do with my PR, I think this is a pre-existing bug that we just don't notice. Since it is hard to repro, I haven't been able to figure out what causes it yet.
  2. Very rarely I get an error related to WebGPU snapshot rendering mode where it thinks the gpu bundle is out of date, and then nothing renders (so rare, but catastrophic). I don't know why this happens, but I'm guessing some kind of timing issue.

For now, I will put this PR in draft.

@ryantrem ryantrem requested a review from Popov72 November 21, 2024 00:27
@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 21, 2024

@rapid-images-tore-levenstam
Copy link
Contributor

If it's of any help regarding the camera movement, I've had a similar issues with camera implementations previously (non-Babylon) when trying to achieve the same thing (render only on change), and the culprit was using lerp/mix functions.
They can sometimes induce this ping-ponging behaviour, but it can be solved by using a special lerp that jumps to the target value when close enough (and the interpoland > 0).

@Popov72
Copy link
Contributor

Popov72 commented Dec 2, 2024

I did some tests with WebGPU but I couldn't reproduce problem #2. I'll try again later, after I've done a PR to fix the morph problems I'm experiencing by testing the MorphStressTest model of the glTF asset repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants